package tank.great.war.frame;

import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

public class TankFrame extends Frame {
  int x = 200, y = 200;
  
  public TankFrame() {
    /* 设置一些 基本属性 */
    setSize(800, 600);
    setResizable(false);
    setTitle("tank great war");
    setVisible(true);
    
    /* 添加 window 监听事件 */
    addWindowListener(new WindowAdapter() {
      @Override
      public void windowClosing(WindowEvent e) {
        /* 直接退出 */
        System.exit(0);
      }
    });
  }
  
  /**
   * 当窗口发生变化时, 会触发该事件
   *
   * @param g the specified Graphics window 类似画笔
   * @author lihh
   */
  @Override
  public void paint(Graphics g) {
    System.out.println("trigger action");
    
    /* 开始 画内容 */
    g.fillRect(x, y, 50, 50);
    x += 10;
    y += 10;
  }
}
